"""
author：fc
date：  2021/10/4
"""
#
# 公用调用函数，对京东人工智能图书数据处理
#
import pandas as pd
import pymysql


def data_deal():
    con = pymysql.connect(host='localhost', user='root', passwd='root', db='datamine', autocommit=True)
    sql = "select * from jd"
    jd_books = pd.read_sql(con=con, sql=sql)
    jd_books['comment'] = jd_books['comment'].str.replace('+', '1')
    jd_books['comment'] = jd_books['comment'].str.replace('万', '000')
    jd_books['comment'] = jd_books['comment'].astype('int')
    jd_books['price'] = jd_books['price'].astype('float')
    print(f"原数据：\n {jd_books.describe()}")
    return jd_books
